home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 9 / FM Towns Free Software Collection 9.iso / t_os / shell / tsbgex / src / win / fb4.asm < prev    next >
Encoding:
Assembly Source File  |  1994-11-16  |  2.5 KB  |  183 lines

  1.     assume    cs:text
  2. text    segment para public 'CODE'
  3.  
  4.     extrn    vramoff:dword
  5.     public    fbread4
  6. fbread4 proc    near
  7.     push    ebp
  8.     push    ebx
  9.     push    ecx
  10.     push    edx
  11.     push    esi
  12.     push    edi
  13.     mov    edi,28[esp]    ; edi <-- save
  14.     mov    edx,36[esp]    ; edx <-- y
  15.     shl    edx,9        ; y * 512
  16.     mov    eax,32[esp]    ; eax <-- x
  17.     sar    eax,1
  18.     add    edx,eax
  19.     add    edx,vramoff    ; edx <-- vram address
  20.     mov    ebp,40[esp]    ; ebp <-- height
  21.     mov    ebx,44[esp]    ; ebx <-- height
  22.     mov    eax,32[esp]
  23.     test    eax,1
  24.     jne    SHORT #10    ; x is odd
  25. #00:
  26.     mov    esi,edx        ; esi <-- vram
  27.     mov    ecx,ebp        ; ecx <-- width
  28. #01:
  29.     mov    al,fs:[esi]
  30.     inc    esi
  31.     mov    [edi],al
  32.     inc    edi
  33.     dec    ecx
  34.     je    SHORT #02
  35.     shr    al,4
  36.     mov    [edi],al
  37.     inc    edi
  38.     loop    #01
  39. #02:
  40.     add    edx,0200H
  41.     dec    ebx
  42.     jne    SHORT #00
  43.     jmp    #end
  44.  
  45. #10:
  46.     mov    esi,edx
  47.     mov    ecx,ebp
  48.     mov    al,fs:[esi]
  49.     inc    esi
  50.     jmp    SHORT #12
  51. #11:
  52.     mov    al,fs:[esi]
  53.     inc    esi
  54.     mov    [edi],al
  55.     inc    edi
  56.     dec    ecx
  57.     je    SHORT #13
  58. #12:
  59.     shr    al,4
  60.     mov    [edi],al
  61.     inc    edi
  62.     loop    #11
  63. #13:
  64.     add    edx,0200H
  65.     dec    ebx
  66.     jne    SHORT #10
  67.     
  68. #end:
  69.     pop    edi
  70.     pop    esi
  71.     pop    edx
  72.     pop    ecx
  73.     pop    ebx
  74.     pop    ebp
  75.     ret
  76. fbread4 endp
  77.  
  78.     public    fbwrite4
  79. fbwrite4 proc    near
  80.     push    ebp
  81.     push    ebx
  82.     push    ecx
  83.     push    edx
  84.     push    esi
  85.     push    edi
  86.     mov    esi,28[esp]    ; esi <-- buf
  87.     mov    edx,36[esp]    ; edx <-- y
  88.     shl    edx,9        ; y * 512
  89.     mov    eax,32[esp]    ; eax <-- x
  90.     sar    eax,1        ; x / 2
  91.     add    edx,eax
  92.     add    edx,vramoff    ; edx <-- vram offset
  93.     mov    ebp,40[esp]    ; ebp <-- width
  94.     mov    ebx,44[esp]    ; ebx <-- height
  95.     mov    eax,32[esp]
  96.     test    eax,1
  97.     jne    SHORT #10    ; x is odd
  98.     
  99. #00:
  100.     mov    edi,edx        ; edi <-- vram
  101.     mov    ecx,ebp        ; ecx <-- width
  102.     shr    ecx,1
  103.     je    #02
  104. #01:
  105.     mov    ax,[esi]
  106.     add    esi,2
  107.     and    al,0fH
  108.     shl    ah,4
  109.     or    al,ah
  110.     mov    fs:[edi],al
  111.     inc    edi
  112.     loop    #01
  113. #02:    
  114.     test    ebp,1
  115.     je    #03
  116.     mov    al,[esi]
  117.     and    al,0fH
  118.     inc    esi
  119.     mov    ah,fs:[edi]
  120.     and    ah,0f0H
  121.     or    ah,al
  122.     mov    fs:[edi],ah
  123.     inc    edi
  124. #03:
  125.     add    edx,0200H
  126.     add    esi,48[esp]
  127.     dec    ebx
  128.     jne    SHORT #00
  129.     jmp    SHORT #end
  130.  
  131. #10:
  132.     mov    edi,edx        ; edi <-- vram
  133.     mov    ecx,ebp        ; ecx <-- width
  134.     mov    al,[esi]
  135.     inc    esi
  136.     shl    al,4
  137.     mov    ah,fs:[edi]
  138.     and    ah,0fH
  139.     or    ah,al
  140.     mov    fs:[edi],ah
  141.     inc    edi
  142.     dec    ecx
  143.     shr    ecx,1
  144.     je    SHORT #12
  145. #11:
  146.     mov    ax,[esi]
  147.     add    esi,2
  148.     and    al,0fH
  149.     shl    ah,4
  150.     or    al,ah
  151.     mov    fs:[edi],al
  152.     inc    edi
  153.     loop    #11
  154. #12:
  155.     test    ebp,1
  156.     jne    #13
  157.     mov    al,[esi]
  158.     and    al,0fH
  159.     inc    esi
  160.     mov    ah,fs:[edi]
  161.     and    ah,0f0H
  162.     or    ah,al
  163.     mov    fs:[edi],ah
  164.     inc    edi
  165. #13:
  166.     add    edx,0200H
  167.     add    esi,48[esp]
  168.     dec    ebx
  169.     jne    SHORT #10
  170.  
  171. #end:
  172.     pop    edi
  173.     pop    esi
  174.     pop    edx
  175.     pop    ecx
  176.     pop    ebx
  177.     pop    ebp
  178.     ret
  179. fbwrite4 endp
  180.  
  181. text    ends
  182.     end
  183.